<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    <link rel="stylesheet" href="./css/selflnformation.css">
    <link rel="stylesheet" href="css/global.css">
    <script src="./js/selflnformation.js"></script>
    <link rel="icon" href="./images/icon.png">
    <title>个人信息</title>
    <!-- <script>
        $(function () {
            let userId = JSON.parse(localStorage.getItem('currentUser'))._id //从登录后保存的本地存储数据中获取用户id
            $.ajax({
                url: "http://localhost:3000/api/getUserInfoById",
                type: 'get',
                data: { userId },
                success: function (res) {
                    if (res.message == "ok") {
                        $('.userName').html('姓名:' + res.user.name)
                        $('.pichead ').attr('src', `http:/ /localhost:3000/${res.user.headpic}`)
                        $('.sex').html(`性别: ${res.user.sex ? '男' : '女'}`)
                        $('.mobile').html(`电话: ${res.user.mobile}`)
                        // $('.birth').html(`生日:${res.user.birth}`)
                        // $('address').html(`地址:${res.user.address}`)
                    } else {
                        alert('个人信息获取失败!')
                    }
                }
            })
        })

        function changePwd() {
            //从登录后保存的本地存储数据中获取用户id
            let userId = JSON.parse(localStorage.getItem('loginUser'))._id
            //获取老密码
            let userOldPwd = $('.oldPwd').val()
            //获取新密码
            let userNewPwd = $('.newPwd').val()
            $.ajax({
                url: 'http://localhost:3000/api/changePwd',
                type: 'post',
                data: { userId, userOldPud, userNewPwd },
                success: function (res) {
                    if (res.message == 'ok') {
                        alert('修改密码成功!')
                    } else {
                        alert(res.message)
                    }
                }
            })
        }


        function selectFile() {
            //打开文件选择框
            $('#headPic').click()
        }

        function uploadHeadPic(file) {
            let userId = JSON.parse(localStorage.getItem('loginUser'))._id //从登录后保存的本地存储数据中获取用户id
            let fd = new FormData()
            //保存上传文件
            fd.append('file', file.files[0])
            //保存上传的用户id
            fd.append('userId', userId)
            $.ajax({
                url: "http://localhost:3000/api/uploadHeadPic",
                type: 'post',
                data: fd,
                processData: false,
                contentType: false,
                success: function (res) {
                    if (res.message == 'ok') {
                        let headpic = `http://localhost:3000/upload/${res.data}`
                        $('.pichead').attr("src", headpic)
                    } else {
                        alert(res.message)
                    }
                }
            })
        }

    </script> -->
</head>

<body>
    <iframe src="./header.html" scrolling="no" frameborder="0" width="100%" height="45px" frameborder="0"></iframe>
    <iframe src="./personalCenter.html" scrolling="no" frameborder="0" width="100%" height="70px" frameborder="0"></iframe>
    <div class="bk1">
        <div class="div" onclick="selFile()">
            <input type="file" name="" id="myFile" onchange="selFiles(this)">
            <img alt="" class="pichead">
        </div>
        <div class="yd">
            <form method="post" action="www.baidu.com" class="bk2"></br>
                <p>
                    &nbsp;<label for="username">姓名：</label><p class="userName"></p>
                </p></br>
                <p>
                    &nbsp;<label for="password">密码：</label><p></p>
                </p></br>
                <p>
                    <!-- &nbsp;性别： <input type="radio" name="性别">男
                    <input type="radio" name="性别">女 -->
                    &nbsp;性别：<p class="sex"></p>
                </p></br>
                <p>
                    &nbsp;<label for="text">手机号：</label><p class="mobile"></p>
                </p></br>
                <p>
                    &nbsp;身份类型:<span>普通用户
                </p></br>
                <p> &nbsp;注册时间: **年*月*日</p></br>
                <p>
                    <input type="reset"  value="修改">
                    <input type="submit" value="保存" class="fhsyy" >
                </p>
            </form>
        </div>
    </div>
    <div id="footer">
        <iframe src="footer.html"  height="320px" width="100%" frameborder="0" scrolling="no"></iframe>
    </div>
</body>

</html>